﻿using HuaJiLedger.Helpers;
using HuaJiLedger.Models.DelayWord;

namespace HuaJiLedger.Repository;

internal class DailyWordRepository
{
    public static DailyWord GetDailyWord()
    {
        var msg = HttpHelper<ApiReponseMsg>.Get("https://www.mxnzp.com/api/daily_word/recommend", "count=1&app_id=ufgjf1piljmtsjqg&app_secret=TU5icFp3cjZEY0JHOUtkWWFNSnFPZz09");

        if (msg.Code == 1)
            return msg.Data[0];

        else
            return new DailyWord
            {
                Content = "网络请求失败，没有获取到每日一句",
                Author = "滑稽"
            };
    }

    public static List<DailyWord> GetDailyWords(int count)
    {
        var msg = HttpHelper<ApiReponseMsg>.Get("https://www.mxnzp.com/api/daily_word/recommend", $"count={count}&app_id=ufgjf1piljmtsjqg&app_secret=TU5icFp3cjZEY0JHOUtkWWFNSnFPZz09");

        if (msg.Code == 1)
            return msg.Data;

        else
            return new List<DailyWord>
            {
                new DailyWord
                {
                    Content = "网络请求失败，没有获取到每日一句",
                    Author = "滑稽"
                }
            };
    }
}